﻿
var hdnChangeDwellingType = $("#hdnChangeDwellingType").val();
var hdngetStatesbyCountry = $("#hdngetStatesbyCountry").val();
var hdnfeatureDetail = $("#hdnfeatureDetail").val();
var hdnUpdatePriority = $("#hdnUpdatePriority").val();

var hdnUserID = $("#hdnUserID").val();
var hdnHomeFeaturesItems = $("#hdnHomeFeaturesItems").val();


jQuery(document).ready(function () {
    jQuery(window).load(function () {
        jQuery("#bodydesk").css('visibility', 'visible');

    });
});



//DWELLING TYPE START


$("#home_name").live("blur", function (e) {
    $("#userchange_home_name").val($(this).val());
});

function checkDwellingtype() {


    // if user changes dwelling type then $("#userchange_dwelling_type") is different from $("#dwelling_type")
    var userchange_dwelling_type = $("#userchange_dwelling_type").val();
    var dwelling_type = $("#dwelling_type").val();

    if (dwelling_type != userchange_dwelling_type) {
        $("#getDwellingType").val(userchange_dwelling_type);
    }

    var home_name = $("#home_name").val();
    var userchange_home_name = $("#userchange_home_name").val();
    if (home_name != userchange_home_name) {
        $("#home_name").val(userchange_home_name);
    }
}

//DWELLING TYPE END

//HOME FEATURES START

//We need to update featurecode string on based of user selection of checkboxes.
//$(".markedChecked").live("change", function (e) {
//    //checkedAddInString();
//});

function checkedCheckonbasedoffeatureString() {
   
    try{
        //give the values to featurestring entity
        var getFeatureString = "";
        $(".markedChecked").each(function (index) {
            var i;
            // values of checkbox checked here
            if ($(this).is(':checked')) {
                getFeatureString = getFeatureString + $(this).attr('data-featurecode') + ',';
            }
        });
        var finalGetFeatureString = getFeatureString.slice(0, -1);
        $("#featurestring").val(finalGetFeatureString);

        var userchange_featurestring = $("#userchange_featurestring").val();
        var featurestring = $("#featurestring").val();
        var getFeaturedata = $('#featurestring').val();
   
        //if user change something, then only this work
        if (userchange_featurestring != '') {
            getFeaturedata = $('#userchange_featurestring').val();

            var arrofgetFeaturedata = getFeaturedata.split(',');

            if (arrofgetFeaturedata != '') {

                $(".markedChecked").each(function (index) {
                    var i;
                    for (i = 0; i < arrofgetFeaturedata.length; ++i) {
                        $(this).attr('checked', false);
                    }
                });
                $(".markedChecked").each(function (index) {
                    var i;

                    for (i = 0; i < arrofgetFeaturedata.length; ++i) {

                        if ($(this).attr('data-featurecode') == arrofgetFeaturedata[i]) {
                            $(this).attr('checked', true);
                        }
                    }
                });


            }
            $("#featurestring").val($('#userchange_featurestring').val());
        }

    }
    catch (err) {

    }
    
}


function checkedAddInString() {

    try{
    var getFeatureString = "";
    $(".markedChecked").each(function (index) {
        var i;
        // values of checkbox checked here
        if ($(this).is(':checked')) {
            getFeatureString = getFeatureString + $(this).attr('data-featurecode') + ',';
        }
    });
    var finalGetFeatureString = getFeatureString.slice(0, -1);
    $("#featurestring").val(finalGetFeatureString);
    $("#userchange_featurestring").val(finalGetFeatureString);
   
    
    }
    catch (err)
    {

    }
}
//HOME FEATURES END


//LOCAL CLIMATE START

//Country State
$("#Country").live("change", function (e) {

    var selectedItem = $(this).val();
    $("#userchange_ps_country").val(selectedItem);
    $("#userchange_ps_state_province").val("");
    var ddlStates = $("#State");
    changeStateAccToCountry(selectedItem, ddlStates);
    window.scrollTo(0, 0);
});


$("#State").live("change", function (e) {
    $("#userchange_ps_state_province").val($(this).val());
    window.scrollTo(0, 0);
});

function checkLocalClimate() {

    var userchange_ps_country = $("#userchange_ps_country").val();
    var userchange_ps_state_province = $("#userchange_ps_state_province").val();

    
    if (userchange_ps_country != '') {
        $("#Country").val(userchange_ps_country);
    }
    if (userchange_ps_state_province != '') {
        var selectedItem = $("#Country").val();
        var ddlStates = $("#State");
        changeStateAccToCountry(selectedItem, ddlStates);

        $("#State").val(userchange_ps_state_province);
    }

}


//LOCAL CLIMATE END

//GOALS START

$("input").live("ifChecked", function (e) {

    var getString = "";
    var FinalgetString = "";
    $(".Goalcheck").each(function (indexTop) {

        $(this).find('.insideGoalcheck').each(function (index) {
            if ($(this).is(':checked')) {
                getString = $(this).val();
            }
        });
        FinalgetString = FinalgetString + getString + ",";
    });

    $("#userchange_ps_goal_string").val(FinalgetString.slice(0, -1));
});

function checkedgoals() {
    var getGoaldata = $('#ps_goal_string').val();

    if ($("#userchange_ps_goal_string").val() != '') {
        getGoaldata = $("#userchange_ps_goal_string").val();
    }

    var arrofgetFeaturedata = getGoaldata.split(',');
    if (arrofgetFeaturedata != '') {
        $(".Goalcheck").each(function (indexTop) {

            $(this).find('.insideGoalcheck').each(function (index) {
                if ($(this).val() == arrofgetFeaturedata[indexTop]) {
                    $(this).attr('checked', true);

                }
            });
        });
    }

}
//GOALS END

//Knowledge Level START

$(".kndata").live("change", function (e) {

    $(".knowledge-data").find('.kndata').each(function (index) {
        $(this).attr('checked', false);
    });
    $(this).attr('checked', true);
    $("#userchange_ps_knowledge_level").val($(this).val());
});

function checkKnowledgeLevel() {

    if ($("#userchange_ps_knowledge_level").val() != '') {
        $(".knowledge-data").find('.kndata').each(function (index) {

            if ($(this).val() == $("#userchange_ps_knowledge_level").val()) {
                $(this).attr('checked', true);

            }
        });
    }
    else {
        $(".knowledge-data").find('.kndata').each(function (index) {

            if ($(this).val() == $("#ps_knowledge_level").val()) {
                $(this).attr('checked', true);

            }
        });
    }
}
//Knowledge Level END

//Priority START

$(".checkpriority").live("change", function (e) {
    $(".checkpriority").each(function (index) {
        $(this).attr('checked', false);
    });
    $(this).attr('checked', true);
    $("#userchange_ps_priority").val($(this).val());
});

function checkpriority() {

    if ($("#userchange_ps_priority").val() != '') {

        $(".checkpriority").each(function (index) {

            if ($(this).val() == $("#userchange_ps_priority").val()) {
                $(this).attr('checked', true);

            }
        });
    }
    else {

        $(".checkpriority").each(function (index) {

            if ($(this).val() == $("#ps_priority").val()) {
                $(this).attr('checked', true);

            }
        });
    }
}
//Priority END

//Monthly Alerts START

$("#chkMob_BadgeAlert").live("click", function (e) {
    if ($(this).is(':checked')) {

        $("#app_mo_alert_badge").val(1);
    }
    else {
        $("#app_mo_alert_badge").val(0);
    }

});
$("#chkMob_PopupAlert").live("click", function (e) {

    if ($(this).is(':checked')) {

        $("#app_mo_alert_popup").val(1);
    }
    else {
        $("#app_mo_alert_popup").val(0);
    }

});

$("#chkMob_BadgeAlert_WebView").live("click", function (e) {
    if ($(this).is(':checked')) {
        
        $("#app_mo_alert_badge").val(1);
    }
    else {
        $("#app_mo_alert_badge").val(0);
    }

});
$("#chkMob_PopupAlert_WebView").live("click", function (e) {

    if ($(this).is(':checked')) {

        $("#app_mo_alert_popup").val(1);
    }
    else {
        $("#app_mo_alert_popup").val(0);
    }

});




$("#getWeekoftheMonth_webview").live("change", function (e) {
    var selectedItem = $(this).val();
    $("#userchange_app_mo_alert_week").val(selectedItem);
    window.scrollTo(0, 0);
});
$("#getDayoftheWeek_webview").live("change", function (e) {
    var selectedItem = $(this).val();
    $("#userchange_app_mo_alert_day").val(selectedItem);
    window.scrollTo(0, 0);
});
$("#getTimeoftheDay_webview").live("change", function (e) {
    var selectedItem = $(this).val();
    $("#userchange_app_mo_alert_hour").val(selectedItem);
    window.scrollTo(0, 0);
});


$("#chkNoAlert").live("click", function (e) {
    //If user checks “No Alerts” then delete email from textbox (and in the database), and  change “No Alerts”   radio button to active

    if ($(this).is(':checked')) {
        //Database ping to delete it.
        var ID = hdnUserID;

        $("#web_mo_alert_email").val('');
        $("#chkemail").attr('checked', false);
    }
    else {
        $("#chkemail").attr('checked', true);
    }
});

$("#chkemail").live("click", function (e) {

    if ($(this).is(':checked')) {

        $("#chkNoAlert").attr('checked', false);
    }
    else {
        $("#chkNoAlert").attr('checked', true);
        $("#web_mo_alert_email").val('');
    }

});


$("#chkweb_mo_alert_email").live("click", function (e) {

    if ($(this).is(':checked')) {

        $("#userchange_web_mo_alert_email_checkbox").val(1);
    }
    else {
        $("#userchange_web_mo_alert_email_checkbox").val(0);
        $("#moweb_mo_alert_email").val('');
        $("#userchange_web_mo_alert_email").val('');
    }

});





$("#web_mo_alert_email").live("keypress", function (e) {

    //If user starts to type in email textbox,then radio button for “Email” becomes active
    $("#chkemail").attr('checked', true);
    $("#chkNoAlert").attr('checked', false);
});



$("#moweb_mo_alert_email").live("keypress", function (e) {

    //If user starts to type in email textbox,then radio button for “Email” becomes active
    $("#chkweb_mo_alert_email").attr('checked', true);

});





$('#web_mo_alert_email').live("keyup", function (e) {

    if (e.which == 8 && this.value.length == 0) {
        $("#chkemail").attr('checked', false);
        $("#chkNoAlert").attr('checked', true);
    }
});


$('#moweb_mo_alert_email').live("keyup", function (e) {

    if (e.which == 8 && this.value.length == 0) {
        $("#chkweb_mo_alert_email").attr('checked', false);

        $("#moweb_mo_alert_email").val('');
        $("#userchange_web_mo_alert_email").val('');
        $("#userchange_web_mo_alert_email_checkbox").val(0);

    }
});






function checkMonthlyAlert() {

    //if ($("#userchange_web_mo_alert_email").val() != '') {
    //    $("#web_mo_alert_email").val($("#userchange_web_mo_alert_email").val());
    //}

    if ($("#web_mo_alert_email").val() == '') {
        $("#chkemail").attr('checked', false);
        $("#chkNoAlert").attr('checked', true);
    }
    else {
        $("#chkemail").attr('checked', true);
        $("#chkNoAlert").attr('checked', false);
    }
}

function AppMonthlyAlerts() {


    if ($("#userchange_web_mo_alert_email_checkbox").val() != '') {

        if ($("#userchange_web_mo_alert_email_checkbox").val() == "0") {
            $("#chkweb_mo_alert_email").attr('checked', false);
            $("#chkweb_mo_alert_email_WebView").attr('checked', false);
            
            $("#moweb_mo_alert_email").val('');

        }
        else if ($("#userchange_web_mo_alert_email_checkbox").val() == "1") {
            $("#chkweb_mo_alert_email").attr('checked', true);
            $("#chkweb_mo_alert_email_WebView").attr('checked', true);
        }
    }
    else {

        //alert("No change");
        if ($("#moweb_mo_alert_email").val() == '') {
            $("#chkweb_mo_alert_email").attr('checked', false);
            $("#chkweb_mo_alert_email_WebView").attr('checked', false);
        }
        else {

            $("#userchange_web_mo_alert_email").val($("#moweb_mo_alert_email").val());
            $("#userchange_web_mo_alert_email").val($("#moweb_mo_alert_email_WebView").val());

            $("#chkweb_mo_alert_email").attr('checked', true);
            $("#chkweb_mo_alert_email_WebView").attr('checked', true);
        }
    }

    if ($("#userchange_web_mo_alert_email").val() != '') {
        $("#moweb_mo_alert_email").val($("#userchange_web_mo_alert_email").val());

        $("#moweb_mo_alert_email_WebView").val($("#userchange_web_mo_alert_email").val());

        $("#chkweb_mo_alert_email").attr('checked', true);
        $("#chkweb_mo_alert_email_WebView").attr('checked', true);
    }


    //if ($("#userchange_app_mo_alert_badge").val() != '') {

    //    try
    //    {

    //        if ($("#userchange_app_mo_alert_badge").val() == '1') {
    //            $("#chkMob_BadgeAlert").attr('checked', true);
    //            $("#chkMob_BadgeAlert_WebView").attr('checked', true);
                
    //        }
    //        else {
    //            $("#chkMob_BadgeAlert").attr('checked', false);
    //            $("#chkMob_BadgeAlert_WebView").attr('checked', false);
    //        }
    //    }
    //    catch (err)
    //    {

    //    }

    //}


    //else {

        try
        {

            if ($("#app_mo_alert_badge").val() == '' || $("#app_mo_alert_badge").val() == '0') {
                $("#chkMob_BadgeAlert").attr('checked', false);
                $("#chkMob_BadgeAlert_WebView").attr('checked', false);
            }

            else {
                $("#chkMob_BadgeAlert").attr('checked', true);
                $("#chkMob_BadgeAlert_WebView").attr('checked', true);
            }
        }
        catch (err) {

        }

    //}

    //if ($("#userchange_app_mo_alert_popup").val() != '') {

    //    try
    //    {


    //        if ($("#userchange_app_mo_alert_popup").val() == '1') {
    //            $("#chkMob_PopupAlert").attr('checked', true);
    //            $("#chkMob_PopupAlert_WebView").attr('checked', true);
    //        }
    //        else {
    //            $("#chkMob_PopupAlert").attr('checked', false);
    //            $("#chkMob_PopupAlert_WebView").attr('checked', false);
    //        }
    //    }
    //    catch (err) {

    //    }
    //}
    //else {

        try
        {


            if ($("#app_mo_alert_popup").val() == '' || $("#app_mo_alert_popup").val() == '0') {
                $("#chkMob_PopupAlert").attr('checked', false);
                $("#chkMob_PopupAlert_WebView").attr('checked', false);
            }
            else {
                $("#chkMob_PopupAlert").attr('checked', true);
                $("#chkMob_PopupAlert_WebView").attr('checked', true);
            }
        }
        catch (err) {

        }
    //}

    if ($("#userchange_app_mo_alert_week").val() != '') {
        $("#getWeekoftheMonth").val($("#userchange_app_mo_alert_week").val());
    }

    if ($("#userchange_app_mo_alert_day").val() != '') {
        $("#getDayoftheWeek").val($("#userchange_app_mo_alert_day").val());
    }

    if ($("#userchange_app_mo_alert_hour").val() != '') {
        $("#getTimeoftheDay").val($("#userchange_app_mo_alert_hour").val());
    }

}




$('.carousel').carousel({
    interval: 2000000
})
//Monthly Alerts END



//Validations START

function Validations() {
    var finalReturnString = "true";

    //check the validations for Local Climate Country State

    if ($("#State option:selected").val() !== undefined) {
        if (($("#State option:selected").val() == "") && ($("#Country option:selected").val() == "US")) {

            alert("You must select a state or region.");
            finalReturnString = "false";
        }
        if (($("#State option:selected").val() == "") && ($("#Country option:selected").val() == "CAN")) {
            alert("You must select a province.");
            finalReturnString = "false";
        }
    }

    if ($("#ps_goal_string").val() !== undefined) {

        //check the validation for goals, if user not selected right show alert message and return false
        if ($("#userchange_ps_goal_string").val() == '0,0,0,0,0,0,0,0,0,0,0,0') {
            alert("You must select at least one goal as either a Top Or Secondary goal.");
            finalReturnString = "false";
        }
    }

    return finalReturnString;

}

//VALIDATIONS END




function CommonAllPartailViews() {
    if (($('.local-climate-data').html().trim() == '') && ($('.goal-data-per').html().trim() == '') && ($('.knowledge-data-outer').html().trim() == '') && ($('.Priority-data-o').html().trim() == '') && ($('#divmon').html().trim() == '')) {

        $('.local-climate-data').html('');
        $(".local-climate-data").load("/Personalization/LocalClimate", function () {
            if ($(this).html() == '') {
                window.location.href = "/Personalization/UpdatePersonalization"
            }
        });


        $('.goal-data-per').html('');
        $(".goal-data-per").load("/Personalization/Goals", function () {
            if ($(this).html() == '') {
                window.location.href = "/Personalization/UpdatePersonalization"
            }
        });

        $('.knowledge-data-outer').html('');
        $(".knowledge-data-outer").load("/Personalization/KnowledgeLevel", function () {
            if ($(this).html() == '') {
                window.location.href = "/Personalization/UpdatePersonalization"
            }
        });


        $('.Priority-data-o').html('');
        $(".Priority-data-o").load("/Personalization/Priority", function () {
            if ($(this).html() == '') {
                window.location.href = "/Personalization/UpdatePersonalization"
            }
        });

        $('#divmon').html('');
        $("#divmon").load("/Personalization/MonthlyAlert", function () {
            if ($(this).html() == '') {
               
                window.location.href = "/Personalization/UpdatePersonalization"
            }
        });

        $('.Dwelling-part-data').html('');
    }


}

//On change of dwelling type we need to change the value of feature string to default values instead of feature string return from database.
// so, make an ajax call and save value in session that user changed the dwelling type.
$("#getDwellingType").live("change", function (e) {

    var DselectedItem = "";
    DselectedItem = $(this).val();
    $("#userchange_dwelling_type").val(DselectedItem);

    $.ajax({
        type: "GET",
        data: { id: $(this).val() },
        url: hdnChangeDwellingType,
        success: function (msg) {
            //$("#userchange_featurestring").val(msg);
            //checkedCheckonbasedoffeatureString();

        }
    });
    //$("#dwellingChanged").val("Yes");
    window.scrollTo(0, 0);
});
//DWELLING TYPE END

//LOCAL CLIMATE START
function changeStateAccToCountry(selectedItem, ddlStates) {
    $.ajax({
        cache: false,
        type: "GET",
        async: false,
        url: hdngetStatesbyCountry,
        data: { "country": selectedItem },
    success: function (data) {
        ddlStates.html('');

        if (selectedItem == "US") {
            ddlStates.append($('<option></option>').val("").html("-Select state or region-"));
        }
        else if (selectedItem == "CAN") {
            ddlStates.append($('<option></option>').val("").html("-Select Province-"));
        }


        $.each(data, function (id, option) {
            ddlStates.append($('<option></option>').val(option.id).html(option.name));
        });

    },
    error: function (xhr, ajaxOptions, thrownError) {
        alert('Failed to retrieve states.');

    }
});
}

//LOCAL CLIMATE END

//Finish Button Click Start
$("#finish").click(function () {
    //if ($("#chkweb_mo_alert_email").is(':checked') && $("#moweb_mo_alert_email").val() == '') {
    if ($("#chkemail").is(':checked') && $("#web_mo_alert_email").val() == '') {
        alert("You must enter the email.");
    }
    else {

        $("#UpdateAllPersonalizationForm").submit();
    }
});
//Finish Button Click END

$(document).ready(function () {

    $("select").live("focusout", function (e) {
        window.scrollTo(0, 0);
    });

    $(".carousel-example-hide").click(function () {

        var returnValue = Validations();
        if (returnValue == "false") {
            return false;
        }
        else {
            $(".back-button").hide();
            var currentvalue = $(this).attr('data-slide-to');
            $(".carousel-indicators li").each(function (index) {
                $(this).removeClass('active1');

            });
            $(".carousel-indicators li").each(function (index) {

                if ($(this).attr('data-slide-to') <= currentvalue) {
                    if (currentvalue == 6) {
                        $("#next").css("display", "none");
                        $("#finish").css("display", "block");
                    }
                    else {
                        $("#next").css("display", "block");
                        $("#finish").css("display", "none");

                    }
                    $(this).addClass('active1');
                }

            });

            $("#back-button").hide();

            var count = '';
            count = $(this).attr('data-slide-to');
            PartialViewsAfterClick(count, "next");
        }
        window.scrollTo(0, 0);
    });

    $("#carousel-example-captions1").click(function () {

        var count = '0';
        PartialViewsAfterClick(count, "first");

        var currentvalue = $(this).attr('data-slide-to');

        $(".carousel-indicators li").each(function (index) {
            $(this).removeClass('active1');

        });
        $(".carousel-indicators li").each(function (index) {

            if ($(this).attr('data-slide-to') <= currentvalue) {
                $(this).addClass('active1');
            }
        });

        $(".back-button").show();
        //If user click directly on circle 1
        $("#next").css("display", "block");
        $("#finish").css("display", "none");
        window.scrollTo(0, 0);
    });

    $("#btnBack").click(function () {
        window.history.back();
    });




    var $first = $('li:first', 'ol'),
     $last = $('li:last', 'ol');
    //Have the first and last li's set to a variable
    //$("#next").live("click", function (e) {
    $("#next").click(function () {

        
        var returnValue = Validations();

        if (returnValue == "false") {
            return false;
        }
        else {

            $(".back-button").hide();
            var $next,
                $selected = $(".active");

            //get the selected item
            // If next li is empty , get the first
            $next = $selected.next('li').length ? $selected.next('li') : $first;

            $selected.addClass("active1");
            $next.addClass('active');


            if ($last.hasClass('active')) {
                $("#next").css("display", "none");
                $("#finish").css("display", "block");
            }
            else {
                $("#next").css("display", "block");
                $("#finish").css("display", "none");
            }

            var count = '';
            $(".carousel-indicators li").each(function () {
                if ($(this).hasClass("active")) {
                    count = $(this).attr('data-slide-to');
                }
            });

            PartialViewsAfterClick(count, "next");
        }
        window.scrollTo(0, 0);
    });

    $("#prev").click(function () {

        $first.next('li')
        var $prev,
            $selected = $(".active");
        // get the selected item
        // If prev li is empty , get the last

        if ($selected.prev('li').prev('li').length == 0) {

            $(".back-button").show();
        }


        var count = '';
        $(".carousel-indicators li").each(function () {
            if ($(this).hasClass("active")) {
                count = $(this).attr('data-slide-to');
            }
        });

        if (count > 0) {
            //if ($selected.prev('li').length >= 1) {
            $prev = $selected.prev('li').length ? $selected.prev('li') : $last;
            $selected.removeClass("active1");

            if ($last.hasClass('active1')) {

                $("#next").css("display", "none");
                $("#finish").css("display", "block");
            }
            else {

                $("#next").css("display", "block");
                $("#finish").css("display", "none");
            }

            PartialViewsAfterClick(count, "previous");
        }
        else {

            return false;
        }

        window.scrollTo(0, 0);
    });

});





$("#web_mo_alert_email").live("blur", function (e) {

    //check that email format  is correct
    if ($(this).val() != '') {
        var returnValue = isValidEmailAddress($(this).val());
        if (returnValue == false) {
            alert("Email address is not in the proper format for a valid email address.");
        }
        else {
            $("#userchange_web_mo_alert_email").val($(this).val());
        }
    }
});

$("#moweb_mo_alert_email").live("blur", function (e) {

    //check that email format  is correct
    if ($(this).val() != '') {
        var returnValue = isValidEmailAddress($(this).val());
        if (returnValue == false) {
            alert("Email address is not in the proper format for a valid email address.");
        }
        else {
            $("#userchange_web_mo_alert_email").val($(this).val());
        }
    }
});


$("#carousel-example-captions").on('slid.bs.carousel', function (event) {

    if ($(this).find('.active').index() == 2) {
        $('.home-features-data').html('');
    }


});


function PartialViewsAfterClick(count, condition) {
    if (condition == "next") {
        //load the div according to our click
        if (count == 1) {

           

            $('.home-features-data').html('');
            $('.home-features-data').load('/Personalization/HomeFeatures', function () {

                if ($(this).html() == '') {
                    window.location.href = "/Personalization/UpdatePersonalization"
                }
                else {
                    
                    
                    if ($("#hdnChangeDT").val() == "True" && $("#hdnActivityType").val() != 'initialSetup') {
                        $("#hfAlert").modal('show');
                       
                    }
                   
                    
                }
            });

            $('.local-climate-data, .goal-data-per, .knowledge-data-outer, .Priority-data-o, #divmon').html('');
        }
        else if (count == 2) {
            //for get the user change checkboxes in entity
                checkedAddInString();

            CommonAllPartailViews();
        }
        else if (count == 3) {

            CommonAllPartailViews();

        }
        else if (count == 4) {
            CommonAllPartailViews();
        }
        else if (count == 5) {

            CommonAllPartailViews();
        }
        else if (count == 6) {
            CommonAllPartailViews();
        }
    }
    else if (condition == "previous") {
        //load the div according to our click

        if (count == 1) {

            //for get the user change checkboxes in entity
            checkedAddInString();

            $('.Dwelling-part-data').html('');
            $(".Dwelling-part-data").load("/Personalization/DwellingType", function () {
                if ($(this).html() == '') {
                    window.location.href = "/Personalization/UpdatePersonalization"
                }
            });

            $('.local-climate-data, .goal-data-per, .knowledge-data-outer, .Priority-data-o, #divmon').html('');
        }
        if (count == 2) {

            $('.home-features-data').html('');
            $(".home-features-data").load("/Personalization/HomeFeatures", function () {
                if ($(this).html() == '') {
                    window.location.href = "/Personalization/UpdatePersonalization"
                }
            });

            $('.local-climate-data, .goal-data-per, .knowledge-data-outer, .Priority-data-o, #divmon').html('');
        }
        else if (count == 3) {
            $('.Dwelling-part-data').html('');

        }
        else if (count == 4) {
            $('.Dwelling-part-data').html('');
        }
        else if (count == 5) {
            $('.Dwelling-part-data').html('');
        }
        else if (count == 6) {
            $('.Dwelling-part-data').html('');
        }

    }
    else if (condition == "first") {
        if (count == 0) {

            $('.Dwelling-part-data').html('');
            $(".Dwelling-part-data").load("/Personalization/DwellingType", function () {
                if ($(this).html() == '') {
                    window.location.href = "/Personalization/UpdatePersonalization"
                }
            });

            $('.local-climate-data, .goal-data-per, .knowledge-data-outer, .Priority-data-o, #divmon').html('');
        }
    }

}

// Personalization markedCheckBox

$(".markedCheckedBox").live("click", function () {      
    var className = $(this).children("a").children("img").attr("class");    
    if (className == "close") {
        $(this).children("a").children("img").attr('src', '../Images/personalization-images/check-mark.png');
        $(this).children("a").children("img").attr('class', 'tik');
    }
    else {
        $(this).children("a").children("img").attr('src', '');
        $(this).children("a").children("img").attr('class', 'close');
    }
});







